import { initExecute } from '../../../../../common/utils/index.js';
import Custom from './Custom.js';
const TableTools = (hook, { ActionButtons, Tree }) => {
	return {
		isJiess: true,
		name: 'TableTools',
		setup({
			midder,
			// 全部的buttons标识
			buttons,
			// 自定表头组件的参数
			custom = true,
			// 其他参数
			...other
		}) {
			const execFun = initExecute.call(this);
			this.add({
				is: ActionButtons,
				...other,
				buttons() {
					const btns = [...buttons];
					if (custom) {
						const config = {
							text: '表头',
							tip: '表头的隐藏与顺序调整',
							onClick: () => {
								this.dialog(show => {
									return {
										width: '360px',
										title: '调整表头',
										children: { is: Custom, midder, hook, Tree },
										okButtonProps: { style: { display: 'none' } },
										cancelButtonProps: { style: { display: 'none' } },
									};
								})
							}
						}
						btns.push(execFun(custom, [config], config));
					}
					return btns;
				},
			})
		}
	};

};
export default TableTools;